<template>
  <div>
    <el-dialog
      width="520px"
      :title="title"
      :close-on-click-modal="false"
      v-dialogDrag
      :visible.sync="visible"
    >

      <el-form label-width="80px" :model="inputForm" :rules="rules" ref="inputForm">
        <el-form-item label="类型:" prop="transProps">
          <el-select clearable v-model="inputForm.transport.transProps"  disabled>
            <el-option
              v-for="item in  $dictUtils.getDictList('transProps')"
              :key="item.value"
              :label="item.label"
              :value="Number(item.value)">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="车牌号" prop="truckNumber">
          <el-input  v-model="inputForm.truckNumber" disabled></el-input>
        </el-form-item>
        <el-form-item label="司机姓名" prop="driverName">
          <el-input  v-model="inputForm.transport.truckDriver.name" disabled></el-input>
        </el-form-item>
        <el-form-item label="司机电话" prop="driverPhone">
          <el-input  v-model="inputForm.transport.truckDriver.phone" disabled></el-input>
        </el-form-item>
        <el-form-item label="车辆类型" prop="axle">
          <el-input v-if="scope" disabled style="width: 70%"></el-input>

          <el-input  v-model="inputForm.transport.axle.axle" disabled style="width: 30%"></el-input>
        </el-form-item>
        <el-form-item label="应收费用" prop="receivableMoney">
          <el-input  v-model="inputForm.receivableMoney"  v-thousands.receivableMoney="inputForm" disabled></el-input>
        </el-form-item>
        <el-form-item label="实收费用" prop="actualMoney">
          <el-input  v-model="inputForm.actualMoney"  v-thousands.actualMoney="inputForm"></el-input>
        </el-form-item>

        <!--  状态(0;停用；1:启用；) -->
        <el-form-item label="支付方式" prop="payMode">
        <el-select clearable v-model="inputForm.payMode" >
          <el-option
            v-for="item in  $dictUtils.getDictList('payType')"
            :key="item.value"
            :label="item.label"
            :value="Number(item.value)">
          </el-option>
        </el-select>
        </el-form-item>

        <el-form-item label="状态" prop="state">
          <el-select clearable v-model="inputForm.state" >
            <el-option
              v-for="item in  $dictUtils.getDictList('loadingFeeState')"
              :key="item.value"
              :label="item.label"
              :value="Number(item.value)">
            </el-option>
          </el-select>
        </el-form-item>


      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="small"  type="primary" @click="doSubmit()" v-noMoreClick>确定</el-button>
        <el-button size="small" @click="visible = false">取消</el-button>
      </span>
    </el-dialog>

  </div>

</template>

<script>

export default {
  data () {
    return {
      visible: false,
      loading: false,
      method: '',
      title: '收取装卸费',
      inputForm: {
        id: '',
        receivableMoney: '',
        actualMoney: '',
        state: 1,
        payMode: 1,
        truckType: 0,
        truckNumber: '',
        transport: {
          driverName: '',
          transProps: 0,
          driverPhone: '',
          truckDriver: {
            name: '',
            phone: ''
          },
          axle: {
            axle: ''
          }
        }
      },
      rules: {
        description: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
        sort: [{ required: true, message: '排列序号', trigger: 'blur' }],
        type: [
          { required: true, message: '代码不能为空', trigger: 'change' }
        ]
      }
    }
  },

  methods: {
  	handleClose(done) {
		this.$Msg.confirm({
			title:'您确定要关闭吗？',
			content:this.GLOBAL.FORM_CLOSE_TIPS,
			confirmCall:()=>{
				done();
			}
		})
	},
    init (row) {
      this.inputForm = row
        this.visible = true
    },
    // 表单提交
    doSubmit () {
      this.$refs['inputForm'].validate((valid) => {
        if (valid) {
          this.loading = true
          this.$http({
            url: `/truck/loading/save`,
            method: 'post',
            data: this.inputForm
          }).then(({ data }) => {
            this.loading = false
            if (data && data.success) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500
              })
              this.visible = false
              this.addChildVisible = false
              this.$emit('refreshDataList')
            }
          })
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
  .hint-container{
    width: 393px;
    height: 11px;
    font-size: 12px;
    font-weight: 400;
    color: #FF1F1F;

  }
</style>
